Concatenate Object Heading (Level 1) and object text (Level 3)

The structure of my DOORS objects is as follows

BUSINESS PROCESS NAME - Object Heading - Level 1
subprocess name - object heading - Level 2
statement 1 - object text - level 3
statement 2 - object text - level 3
statement 3 -object text - level 3

I want to create a layout DXL column that concatenates the BUSINESS PROCESS NAME to each of the statements

the result of the concatenation would be
i.e BUSINESS PROCESS NAME: statement1
BUSINESS PROCESS NAME: statement2
BUSINESS PROCESS NAME: statement3
Any help with writing DXL is greatly appreciated
dxlnovice - Wed Jan 13 22:09:07 EST 2010

Re: Concatenate Object Heading (Level 1) and object text (Level 3)
llandale - Thu Jan 14 14:18:36 EST 2010

Perhaps start with this:
 

int L1 = level(obj)
string Display = ""
 
if (L1 == 3)
{  oName = parent(parent(obj))
   Display = oName."Object Heading"
   if (!null Display) Display = Display ": "
}
 
displayRich(Display (obj."Object Text")

Re: Concatenate Object Heading (Level 1) and object text (Level 3)
dxlnovice - Thu Jan 14 14:57:46 EST 2010

Thanks for all your quick responses

Re: Concatenate Object Heading (Level 1) and object text (Level 3)
SystemAdmin - Thu Jan 14 17:50:27 EST 2010

llandale - Thu Jan 14 14:18:36 EST 2010

Perhaps start with this:
 

int L1 = level(obj)
string Display = ""
 
if (L1 == 3)
{  oName = parent(parent(obj))
   Display = oName."Object Heading"
   if (!null Display) Display = Display ": "
}
 
displayRich(Display (obj."Object Text")

Louie - just as a matter of interest, can this also be done as a recursive function for situations where the depth of an object w.r.t. it's root parent object is not a fixed value?
Paul Miller

Re: Concatenate Object Heading (Level 1) and object text (Level 3)
Peter_Albert - Fri Jan 15 04:16:48 EST 2010

SystemAdmin - Thu Jan 14 17:50:27 EST 2010
Louie - just as a matter of interest, can this also be done as a recursive function for situations where the depth of an object w.r.t. it's root parent object is not a fixed value?


Paul Miller

You don't need recursion for this. This small script returns the (grand-) parent object w.r.t. a given object level (either absolute e.g. 1 for root parent object, i.e. at level 1; or relative e.g. -2 for an object 2 levels above the input object)
{code}// Find (grand-)parent object at given level
/*
Find the respective (grand-)parent object at a specified level in the
object hierarchy

USAGE

Object getParentObj(Object obj, int iLevel)

iLevel > 0: absolute value specifying the (grand-)parent object's level
iLevel < 0: relative value of (grand-)parent object's level in relation
to the input object's level
iLevel = 0: return input object
*/

pragma runLim, 0

Object getParentObj(Object obj, int iLevel)
{ // Find (grand-)parent object at given level
Object pObj = null
int iObjLevel
int i
if (!null obj)
{ // Object is not null
iObjLevel = level obj
if (iLevel == 0){pObj = obj}
else
{ // Specified level is not 0
if (iLevel > 0)
{ // Object level specified as absolute value
// Calculate respective relative level
iLevel = iLevel - iObjLevel
} // Object level specified as absolute value
if (iLevel < 0)
{ // Check for absolute level values below input object level
pObj = obj
for i in 1: -1 * iLevel do
{ // Move upwards through object hierarchy
pObj = parent pObj
if (null pObj){break}
} // Move upwards through object hierarchy
} // Check for absolute level values below input object level
} // Specified level is not 0
} // Object is not null
return pObj
} // Find (grand-)parent object at given level
}

Peter

Re: Concatenate Object Heading (Level 1) and object text (Level 3)
Peter_Albert - Fri Jan 15 04:18:14 EST 2010

Peter_Albert - Fri Jan 15 04:16:48 EST 2010
You don't need recursion for this. This small script returns the (grand-) parent object w.r.t. a given object level (either absolute e.g. 1 for root parent object, i.e. at level 1; or relative e.g. -2 for an object 2 levels above the input object)
{code}// Find (grand-)parent object at given level
/*
Find the respective (grand-)parent object at a specified level in the
object hierarchy

USAGE

Object getParentObj(Object obj, int iLevel)

iLevel > 0: absolute value specifying the (grand-)parent object's level
iLevel < 0: relative value of (grand-)parent object's level in relation
to the input object's level
iLevel = 0: return input object
*/

pragma runLim, 0

Object getParentObj(Object obj, int iLevel)
{ // Find (grand-)parent object at given level
Object pObj = null
int iObjLevel
int i
if (!null obj)
{ // Object is not null
iObjLevel = level obj
if (iLevel == 0){pObj = obj}
else
{ // Specified level is not 0
if (iLevel > 0)
{ // Object level specified as absolute value
// Calculate respective relative level
iLevel = iLevel - iObjLevel
} // Object level specified as absolute value
if (iLevel < 0)
{ // Check for absolute level values below input object level
pObj = obj
for i in 1: -1 * iLevel do
{ // Move upwards through object hierarchy
pObj = parent pObj
if (null pObj){break}
} // Move upwards through object hierarchy
} // Check for absolute level values below input object level
} // Specified level is not 0
} // Object is not null
return pObj
} // Find (grand-)parent object at given level
}

Peter

Now hopefully properly formatted (the preview button seems to have disappeared)
 

// Find (grand-)parent object at given level
/*
Find the respective (grand-)parent object at a specified level in the
object hierarchy

USAGE

Object getParentObj(Object obj, int iLevel)

iLevel > 0: absolute value specifying the (grand-)parent object's level
iLevel < 0: relative value of (grand-)parent object's level in relation 
to the input object's level
iLevel = 0: return input object
*/
 
pragma runLim, 0
 
Object getParentObj(Object obj, int iLevel)
{ // Find (grand-)parent object at given level
  Object pObj = null
  int iObjLevel
  int i
  if (!null obj)
  { // Object is not null
    iObjLevel = level obj
    if (iLevel == 0){pObj = obj}
    else 
    { // Specified level is not 0
      if (iLevel > 0)
      { // Object level specified as absolute value
        // Calculate respective relative level
        iLevel = iLevel - iObjLevel
      } // Object level specified as absolute value
      if (iLevel < 0)
      { // Check for absolute level values below input object level
        pObj = obj
        for i in 1: -1 * iLevel do
        { // Move upwards through object hierarchy
          pObj = parent pObj
          if (null pObj){break}
        } // Move upwards through object hierarchy
      } // Check for absolute level values below input object level
    } // Specified level is not 0
  } // Object is not null
  return pObj
} // Find (grand-)parent object at given level

Re: Concatenate Object Heading (Level 1) and object text (Level 3)
llandale - Fri Jan 15 12:57:12 EST 2010

SystemAdmin - Thu Jan 14 17:50:27 EST 2010
Louie - just as a matter of interest, can this also be done as a recursive function for situations where the depth of an object w.r.t. it's root parent object is not a fixed value?


Paul Miller

I think you are saying that a particular 'root parent' object can have applicable descendents at various levels. I would use a 'while' statement, but if you REALLY MUST use recursion, perhaps due FSC, Fancy-Code-Syndrom, it may look like this:

bool   IsParentRootObject(Object obj)
{      // Is this object a parent root object?
    if (null obj) return(false)
 
     // You must right this code yourself.
    return(True or False)
}   // end IsParentRootObject()
 
 
Object  GetParentRootObject(Object oChild)
{    // Find the parent root object for this child object
     // ** Recursion Enabled **
     // A parent root object has no parent, parent-root-object
 
    if (null oChild)                return(null)
    if (IsParentRootObject(oChild)) return(null)
 
    Object oParent = parent(oChild)
    if (null oParent) //-
    then return(null)
    elseif (IsParentRootObject(oParent)) //-
    then return(oParent)
    else return(GetParentRootObject(oParent))  // ** Recursion Here **
}   // end GetParentRootObject()

 


If there are additional restrictions, such as a root object must be at least 2 levels above, then it gets stickier. Perhaps both function have an additional parameter, Object oOriginal, which is the original object called by source programs: Object oRoot = GetParentRootObject(oCurrent, oCurrent). IsParentRootObject does extra checking against that.

 

 

 

  • Louie